package com.nondo.rdp.finance.domain.product;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import com.nondo.rdp.finance.config.DbConfig;
import org.hibernate.validator.constraints.Length;

import com.nondo.rdp.core.domain.base.BaseEntity;
import com.nondo.rdp.core.domain.attach.Attach;

/**
 * 交易-证券开户
 */
@Entity
@Table(name = DbConfig.DEFAULT_TABLE_PREFIX + "security_open")
public class SecurityOpen extends BaseEntity {
	private static final long serialVersionUID = 759411512915288864L;
	private Long id; // 主键
	private String title; // 标题
	private Attach image;// logo
	private String description; // 描述
	private String url;// 开户url
	private int sort;// 排序
	private int home;// 是否放置首页 0|1
	private int isShow;// 是否显示0|1

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@NotNull(message = "标题不能为空")
	@Length(min = 1, max = 32, message = "标题长度不能超过32个字符")
	@Column(name = "title", length = 32)
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@NotNull(message = "产品描述不能为空")
	@Column(name = "description", columnDefinition = "text")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "image")
	public Attach getImage() {
		return image;
	}

	public void setImage(Attach image) {
		this.image = image;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(columnDefinition = "int default 0", nullable = false)
	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	@Column(columnDefinition = "int default 0", nullable = false)
	public int getHome() {
		return home;
	}

	public void setHome(int home) {
		this.home = home;
	}

	@Column(columnDefinition = "int default 0", nullable = false)
	public int getIsShow() {
		return isShow;
	}

	public void setIsShow(int isShow) {
		this.isShow = isShow;
	}

}
